from django.shortcuts import render
from django.http import HttpResponse, HttpResponseNotFound, HttpResponseRedirect
from django.urls import reverse

# Create your views here.

week = {'monday': '1', 'tuesday': '2', 'wednesday': '3', 'thursday': '4', 'friday': '5', 'saturday': '6', 'sunday': '7'}


def get_info_bout_tasks_for_da_week(request, tasks_for_days: str):
    if tasks_for_days in list(week):
        return HttpResponse(f"Сегодня {week[tasks_for_days]} день недели")
    else:
        return HttpResponseNotFound(f"Неверный номер дня - {tasks_for_days}")


def redirect_to_day_of_week(request, tasks_for_days: int):
    if str(tasks_for_days) not in list(week.values()):
        return HttpResponseNotFound(f"Неверный номер дняzz - {tasks_for_days}")
    else:
        day_week = list(week)[tasks_for_days - 1]
        redirect_url = reverse('task-for-week', args=(day_week, ))
        return HttpResponseRedirect(redirect_url)


def view_statis_html_page_task_week(request):
    return render(request, 'week_days/greeting.html')